home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Befund2A.cpp < prev    next >
C/C++ Source or Header  |  1998-12-18  |  2KB  |  55 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Befund2A.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8.  
  9. const String DateiName = "Diagnose.txt";
  10. TForm1 *Form1;
  11. TStringList *Diagnose;
  12. int Nr;
  13.  
  14. //---------------------------------------------------------------------------
  15. __fastcall TForm1::TForm1(TComponent* Owner)
  16.     : TForm(Owner)
  17. {
  18. }
  19. //---------------------------------------------------------------------------
  20. void __fastcall TForm1::FormCreate(TObject *Sender)
  21. {
  22.   randomize ();
  23.   Diagnose = new TStringList;
  24.   try
  25.   {
  26.     Diagnose->LoadFromFile (DateiName);
  27.   }
  28.   catch (...)
  29.   {
  30.     Diagnose->Add ("Keine Sprechstunde");
  31.     Diagnose->Add ("Praxis geschlossen");
  32.     Diagnose->Add ("Hilf Dir selbst!");
  33.   }
  34.   ScrollBar1->Min = 0;
  35.   ScrollBar1->Max = Diagnose->Count - 1;
  36. }
  37. //---------------------------------------------------------------------------
  38. void __fastcall TForm1::Button1Click(TObject *Sender)
  39. {
  40.   Panel1->Caption = "";
  41.   Edit1->Text = "";
  42.   Edit1->SetFocus ();
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TForm1::Button2Click(TObject *Sender)
  46. {
  47.   Nr = random (Diagnose->Count);
  48.   Panel1->Caption = Diagnose->Strings[Nr];
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TForm1::ScrollBar1Change(TObject *Sender)
  52. {
  53.   Panel1->Caption = Diagnose->Strings[ScrollBar1->Position];    
  54. }
  55. //---------------------------------------------------------------------------